$(document).ready(function() {
    
    
    
    // auto complete
    $("#client_referral_name").select2();
    
    //Logic for toggle

  
     
    
 $( "body" ).delegate( ".item-class", "click", function() {
 
 //$('.item-class').click( function(){
    if ($(this).hasClass('item-open') ) {
      var id = $(this).attr('href');
      $(id).hide('slow');
      $(this).removeClass('item-open');
      $(this).addClass('collapsed');
      return false;
    }
    $('.item-class').addClass('collapsed');

    $('.item-class').removeClass('item-open');
    $(this).addClass('item-open');

    $('.item-container').hide('slow');
    var id = $(this).attr('href');

    $(this).removeClass('collapsed');

    $(id).show('slow');
    return false;
 });
 
 
 
 
 
 $(".wysihtml5-editor").each(function() {
        $(this).wysihtml5({
            "font-styles": true, //Font styling, e.g. h1, h2, etc. Default true
            "emphasis": true, //Italics, bold, etc. Default true
            "lists": true, //(Un)ordered lists, e.g. Bullets, Numbers. Default true
            "html": false, //Button which allows you to edit the generated HTML. Default false
            "link": false, //Button to insert a link. Default true
            "image": false, //Button to insert an image. Default true,
            "color": false//Button to change color of font  
        });
    });
    
    
    
//Drag n Drop up-loader for DOCUMENT
    Dropzone.autoDiscover = false;
    //Drag n Drop up-loader for EXTRA_IMAGE
    var paramsdata = {};
    paramsdata['UNIQUEIDENTIFIER'] = UNIQUEIDENTIFIER;
    
    $(".document_dropzone").dropzone(
            {
                url: BASE_PATH + '/member/upload',
                paramName: 'DOCUMENT',
                params: paramsdata,
                maxFilesize: 500,
               // acceptedFiles: ".ppt,.pptx,.xls,.xlsx,.odp,.doc,.docx,.pdf,.ppsx",
            }
    );
     
      $('.member-country').change(function() {
          
        var postdata = {};
        var country_id = $(this).val();
        if (country_id === '') {
        } else {
            postdata['country_id'] = country_id;
            jQuery.post(BASE_PATH + '/member/getcitylist', postdata, function(result) {
                $('.member-city').html(result);
            });
        }

    });
    
    $('.mem_client_type').click(function(){
         //var client_type = $(this).val();
         //alert($("#user_type_"+client_type).is(':checked'));
         
         if($("#user_type_buyer").is(':checked')== false && $("#user_type_tenant").is(':checked') == false ){
             $('.client_datepicker').hide();
             $('.client_note').hide();
             $("#mem_client_status").val('');
         }
         
         if($("#user_type_buyer").is(':checked') || $("#user_type_tenant").is(':checked') ){
            $('.client_status').removeClass('display-none'); 
            
            $('.client_status').show();
         }else{
             $('.client_status').hide();
         }
         
    });
    
    
    $('.member-client-status').change(function(){
        
         var client_status = $(this).val();
        
         if(client_status == 'pending' || client_status == 'incubated'){
            $('.client_datepicker').removeClass('display-none'); 
            $('.client_datepicker').show();
            $('.client_note').removeClass('display-none'); 
            $('.client_note').show();
         }else{
             $('.client_datepicker').hide();
             $('.client_note').hide();
         }
    });
    
    //show client datepicker and note 
    if($("#show_client_datepicker").val() == 1 ){
            $('.client_datepicker').removeClass('display-none'); 
            $('.client_datepicker').show();
            $('.client_note').removeClass('display-none'); 
            $('.client_note').show();
    }
    
    if($("#show_client_status").val() == 1 ){
         $('.client_status').removeClass('display-none'); 
         $('.client_status').show();
    }
    
    
    $('#mem_bday').datepicker({
            format: "yyyy-mm-dd",
            startView: 1,
            daysOfWeekDisabled: "3,4",
            autoclose: true,
            todayHighlight: true
    });
    
     $('#mem_client_calender').datepicker({
            format: "yyyy-mm-dd",
            autoclose: true,
            todayHighlight: true
     });
    
     
});
	 